#include <iostream>

#include <cstdio>

#include <algorithm>

using namespace std;

const int maxn =5e5+10;

pair<int,int> order[maxn];


int seg[maxn <<2];

void build(int l,int r,int rt)

{

    if(l == r)

    {

        seg[rt] =0;

        return;

    }

    int mid = (l + r) >>1;

    build(l, mid, rt <<1);

    build(mid +1, r, rt << 1 |1);

}

long long query(int ql,int qr,int l,int r,int rt)

{

    if(ql <= l && r <= qr)return seg[rt];

    long long res =0;

    int mid = (l + r) >>1;

    if(ql <= mid) res +=query(ql, qr, l, mid, rt <<1);

    if(mid < qr) res +=query(ql, qr, mid + 1, r, rt << 1 |1);

    return res;

}

void update(int num,int l,int r,int rt)

{

    if(l == r)

    {

        seg[rt] ++;

        return;

    }

    int mid = (l + r) >>1;

    if(num <= mid)update(num, l, mid, rt <<1);

    if(num > mid)update(num, mid + 1, r, rt << 1 |1);

    seg[rt] =seg[rt << 1] +seg[rt << 1 |1];

}

int main()

{

    int n;

    cin >> n;

    long long sum =0;

    build(1, n,1);

    for (int i =1; i <= n; i ++) {

        scanf("%d",&order[i].first);

        order[i].second = i;

    }

    sort(order +1,order +1 + n);

    for (int i =1; i <= n; i ++) {

        sum += query(order[i].second, n,1, n,1);

        update(order[i].second,1, n, 1);

    }

    cout << sum <<endl;

    return 0;

}
